package client

import (
	"github.com/gin-gonic/gin"
	"test_demo/framwork/msg"
	"test_demo/models/tables"
)

type UserService struct {
	tables.User

}

func (c *UserService) Add(g *gin.Context)  {
	user:=new(tables.User)
	user.Username=c.Username
	_,err:=user.QueryOne(*user)
	if err==nil{
		msg.Error(g,"用户名重复")
		return
	}
	user.Password=c.Password
	err=user.Add(*user)
	if err!=nil{
		msg.Error(g,"用户添加失败")
		return
	}
	msg.Sucess(g,"用户添加成功")
	return
}
